import axios from "axios"
import {Component  } from "react";
import PropTypes from 'prop-types'
import List from "./list";

//  List.propTypes = {
//   list:PropTypes.array,
// }
class App extends Component{
  state={
    list:[],
    list1:[1,2,3]
  }
  static propTypes={
    list:PropTypes.array,
  }
componentDidMount(){
  this.getList()
}
  getList=async()=>{
    const res=await axios.get('http://ajax-api.itheima.net/api/news')
    console.log(res.data.data);
    this.setState({
      list:res.data.data
    },()=>{
      console.log('list',this.state.list);
    })
   
  }

  render(){
    return(
      <div>
        <h1>新闻列表</h1>
        <List list={this.state.list}/>
      </div>
    )
  }
}

export default App